//
//  HomePageViewController.m
//  瞬间
//
//  Created by dlios on 15-6-29.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HomePageViewController.h"
#import "RadioViewController.h"
#import "ReadingViewController.h"
#import "CommunityViewController.h"

@interface HomePageViewController ()<UITableViewDataSource,UITableViewDelegate>;

@property (nonatomic, retain) UITableView *LeftTableView;
@property (nonatomic, retain) NSArray *nameArr;

@property (nonatomic, retain) UIView *headView;

@end



@implementation HomePageViewController

- (void)dealloc
{
    [_LeftTableView release];
    [_nameArr release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.nameArr = @[@"首页", @"电台", @"阅读", @"社区"];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.LeftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    self.LeftTableView.delegate = self;
    self.LeftTableView.dataSource = self;
//    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"3.jpg"]];
//    [self.LeftTableView setBackgroundColor:color];
    [self.view addSubview:self.LeftTableView];
    [_LeftTableView release];
    
    self.headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.LeftTableView.frame.size.width, 200)];
    [self.headView setBackgroundColor:[UIColor clearColor]];
    self.headView.backgroundColor = [UIColor lightGrayColor];
//    self.LeftTableView.tableHeaderView = self.headView;
    [self.view addSubview:self.headView];
    [_headView release];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.nameArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse] autorelease];
    }
    cell.textLabel.text = self.nameArr[indexPath.row];
    cell.backgroundColor = [UIColor clearColor];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        [self.LeftTableView reloadData];
    } else if (indexPath.row == 1) {
        RadioViewController *radio = [[RadioViewController alloc] init];
        [radio setModalTransitionStyle:0];
        [self presentViewController:radio animated:YES completion:^{
            
        }];
    } else if (indexPath.row == 2){
        ReadingViewController *read = [[ReadingViewController alloc] init];
        [read setModalTransitionStyle:0];
        [self presentViewController:read animated:YES completion:^{
            
        }];
    } else {
        CommunityViewController *community = [[CommunityViewController alloc] init];
        [community setModalTransitionStyle:0];
        [self presentViewController:community animated:YES completion:^{
            
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
